import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '故事名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '章节',
    align:"center",
    dataIndex: 'chapterId_dictText'
   },
   {
    title: '视频资源',
    align:"center",
    dataIndex: 'resourceId_dictText'
   },
   {
    title: '流转视频',
    align:"center",
    dataIndex: 'nextResourceId_dictText'
   },
   {
    title: '按钮时机',
    align:"center",
    dataIndex: 'buttonTiming'
   },
   {
    title: '奖励',
    align:"center",
    dataIndex: 'award'
   },
   {
    title: '开启人物',
    align:"center",
    dataIndex: 'openCharacter_dictText'
   },
   {
    title: '排序',
    align:"center",
    sorter: true,
    dataIndex: 'sort'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "故事名称",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "章节",
      field: 'chapterId',
      component: 'JSearchSelect',
      componentProps:{
         dict:"m_chapter,name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "开启人物",
      field: 'openCharacter',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"m_character_info,name,id"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '故事名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '章节',
    field: 'chapterId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"m_chapter,name,id"
    },
  },
  {
    label: '视频资源',
    field: 'resourceId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"m_resource,name,id"
    },
  },
  {
    label: '流转视频',
    field: 'nextResourceId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"m_resource,name,id"
    },
  },
  {
    label: '按钮时机',
    field: 'buttonTiming',
    component: 'Input',
  },
  {
    label: '奖励',
    field: 'award',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+$/, message: '请输入整数!'},
          ];
     },
  },
  {
    label: '开启人物',
    field: 'openCharacter',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"m_character_info,name,id"
     },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '故事名称',order: 0,view: 'text', type: 'string',},
  chapterId: {title: '章节',order: 1,view: 'sel_search', type: 'string',dictTable: "m_chapter", dictCode: 'id', dictText: 'name',},
  resourceId: {title: '视频资源',order: 2,view: 'sel_search', type: 'string',dictTable: "m_resource", dictCode: 'id', dictText: 'name',},
  nextResourceId: {title: '流转视频',order: 3,view: 'sel_search', type: 'string',dictTable: "m_resource", dictCode: 'id', dictText: 'name',},
  buttonTiming: {title: '按钮时机',order: 4,view: 'text', type: 'string',},
  award: {title: '奖励',order: 5,view: 'number', type: 'number',},
  openCharacter: {title: '开启人物',order: 6,view: 'list', type: 'string',dictTable: "m_character_info", dictCode: 'id', dictText: 'name',},
  sort: {title: '排序',order: 7,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}